﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Public;
using System.Data;

namespace DAL
{
    public class KhachHangDAL
    {
        clsKetNoi kn = new clsKetNoi();
        public DataTable LoadKhachHang()
        {
            return kn.LayDuLieu("KhachHang_Load");
        }
        ///Tìm kiếm
        public DataTable TimKiem(KhachHangPublic kh)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaKhachHang";
            value[0] = kh.MaKhachHang;
            return kn.LayDuLieu("KhachHang_Search", name, value, Nparameter);
        }
        //Thêm
        public int ThemKhachHang(KhachHangPublic kh)
        {
            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaKhachHang";value[0] = kh.MaKhachHang;
            name[1] = "@TenKhachHang";value[1] = kh.TenKhachHang;
            name[2] = "@CMND";value[2] = kh.CMND;
            name[3] = "@DienThoai";value[3] = kh.DienThoai;
            return kn.Update("KhachHang_Insert", name, value, Nparameter);
        }
        public DataTable TimHanhKhach(KhachHangPublic p)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaKhachHang";
            value[0] = p.MaKhachHang;
            return kn.LayDuLieu("HanhKhach_Search",name,value,Nparameter);
        }
        
    }
}
